/**
 * @name: comment.service
 * @data: 2024/6/1 11:35
 */
import {Provide} from "@midwayjs/core";
import {InjectEntityModel} from "@midwayjs/typeorm";
import Comment from "../pojo/entity/comment.entity";
import {Repository} from "typeorm";

/**
 * @description 评论service
 */
@Provide()
export class CommentService{
  @InjectEntityModel(Comment)
  commentModel: Repository<Comment>;

  /**
   * @description 新增评论
   * @param comment
   */
  async insertComment(comment:Comment){
    return await this.commentModel.save(comment);
  }

  /**
   * @description 根据文章id查询评论列表
   * @param title
   */
  async selectCommentListByArticleId(articleId: number) {
    return await this.commentModel.query(`select * from comment where article_id = ${articleId}`);
  }

}
